package rkw;

import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import rkw.config.ApplicationConfig;
import rkw.config.PersistenceConfig;
import rkw.config.PersistenceMySqlConfig;
import rkw.gui.MainWindow;
import core.utils.ConfigPropertiesHolder;
import core.utils.Property;

public class Application {
	public static void main(String[] args) {
		ApplicationContext context;
		if (ConfigPropertiesHolder.getInstance().getProperty(Property.EMBEDDED).equals("true")) {
			context = new AnnotationConfigApplicationContext(PersistenceConfig.class, ApplicationConfig.class);
		} else {
			context = new AnnotationConfigApplicationContext(PersistenceMySqlConfig.class, ApplicationConfig.class);
		}
		MainWindow mainWindow = context.getBean(MainWindow.class);
		mainWindow.open();
		((ConfigurableApplicationContext) context).close();
	}
}
